﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Administration/Administration.Master"
    AutoEventWireup="true" CodeBehind="CadreDidactice.aspx.cs" Inherits="IEWebSite.Administration.CadreDidactice" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .MyImageButton
        {
            cursor: hand;
        }
        .EditFormHeader td
        {
            font-size: 14px;
            padding: 4px !important;
            color: Green;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <h1>
        Cadre didactice</h1>
    <asp:SqlDataSource ID="profesorSqlGetTitluDidactic" runat="server" ConnectionString="<%$ ConnectionStrings:SiteIEConnectionString %>"
        SelectCommand="SELECT [TitluDidactic], [IdSysTitluDidactic] FROM [SysTitluDidactic] ORDER BY [TitluDidactic]">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="profesorSqlGetTitluStiintific" runat="server" ConnectionString="<%$ ConnectionStrings:SiteIEConnectionString%>"
        SelectCommand="SELECT [IdSysTitluStiintific], [TitluStiintific] FROM [SysTitluStiintific] ORDER BY [TitluStiintific]">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="profesorSqlGetColective" runat="server" ConnectionString="<%$ ConnectionStrings:SiteIEConnectionString %>"
        SelectCommand="SELECT [IdSysColectiv], [SysNumeColectiv] FROM [SysColectiv] ORDER BY [SysNumeColectiv]">
    </asp:SqlDataSource>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

        <script type="text/javascript">
            function RowDblClick(sender, eventArgs) {
                sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }

            function validateRadUpload(source, e) {
                e.IsValid = false;

                var upload = $find(source.parentNode.getElementsByTagName('div')[0].id);
                var inputs = upload.getFileInputs();
                for (var i = 0; i < inputs.length; i++) {
                    //check for empty string or invalid extension
                    if (inputs[i].value != "" && upload.isExtensionValid(inputs[i].value)) {
                        e.IsValid = true;
                        break;
                    }
                }
            }
        </script>

    </telerik:RadCodeBlock>
    <telerik:RadGrid ID="rdgProfesor" GridLines="None" runat="server" AllowAutomaticDeletes="True"
        AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True"
        AutoGenerateColumns="False" DataSourceID="DataSourceProf" OnItemUpdated="RadGrid1_ItemUpdated"
        OnItemDeleted="RadGrid1_ItemDeleted" 
        OnItemInserted="RadGrid1_ItemInserted" OnDataBound="RadGrid1_DataBound"
        Skin="Sunset" onitemcreated="RadGrid1_ItemCreated">
        <PagerStyle Mode="NextPrevAndNumeric" />
        <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="IdPerosnalDidactic"
            DataSourceID="DataSourceProf" HorizontalAlign="NotSet" AutoGenerateColumns="False">
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                    <ItemStyle CssClass="MyImageButton" />
                </telerik:GridEditCommandColumn>
                <telerik:GridBinaryImageColumn DataField="Poza" HeaderText="Image" UniqueName="Upload"
                    ImageAlign="NotSet" ImageHeight="80px" ImageWidth="80px" ResizeMode="Fit" DataAlternateTextFormatString="Image of {0}">
                    <HeaderStyle Width="90px" />
                </telerik:GridBinaryImageColumn>
                <telerik:GridBoundColumn DataField="Nume" HeaderText="Nume" SortExpression="Nume"
                    UniqueName="Nume" ColumnEditorID="GridTextBoxColumnEditorNume">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Prenume" HeaderText="Prenume" SortExpression="Prenume"
                    UniqueName="Prenume" ColumnEditorID="GridTextBoxColumnEditorPrenume">
                </telerik:GridBoundColumn>
                <telerik:GridDropDownColumn  DataField="IdSysTitluDidactic" DataSourceID="profesorSqlGetTitluDidactic"
                    HeaderText="Titlu didactic" ListTextField="TitluDidactic" ListValueField="IdSysTitluDidactic"
                    UniqueName="IdSysTitluDidactic">
                </telerik:GridDropDownColumn>
                <telerik:GridDropDownColumn DataField="IdSysTitluStiintific" DataSourceID="profesorSqlGetTitluStiintific"
                    HeaderText="Titlu stiintific" ListTextField="TitluStiintific" ListValueField="IdSysTitluStiintific"
                    UniqueName="IdSysTitluStiintific">
                </telerik:GridDropDownColumn>
                <telerik:GridDropDownColumn DataField="IdSysColectiv" DataSourceID="profesorSqlGetColective"
                    HeaderText="Colectiv" ListTextField="SysNumeColectiv" ListValueField="IdSysColectiv"
                    UniqueName="IdSysColectiv">
                </telerik:GridDropDownColumn>
                <telerik:GridBoundColumn DataField="WebSite" HeaderText="Web site" SortExpression="WebSite"
                    UniqueName="WebSite" ColumnEditorID="GridTextBoxColumnEditorWebSite">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Email" HeaderText="Email" SortExpression="Email"
                    UniqueName="Email" ColumnEditorID="GridTextBoxColumnEditorEmail">
                </telerik:GridBoundColumn>
                <telerik:GridButtonColumn ConfirmText="Stergeti profesorul?" ConfirmDialogType="RadWindow"
                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                    UniqueName="DeleteColumn">
                    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                </telerik:GridButtonColumn>
            </Columns>
            <EditFormSettings ColumnNumber="2" CaptionDataField="Nume" CaptionFormatString="Editati datele cadului didactic {0}">
                <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
                    Width="100%" />
                <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                <EditColumn ButtonType="ImageButton" InsertText="Adaugati un profesor" UpdateText="Updatati o inregistrare"
                    UniqueName="EditCommandColumn1" CancelText="Anulati editarea">
                    <ItemStyle CssClass="MyImageButton" />
                </EditColumn>
                <FormTableButtonRowStyle HorizontalAlign="Right"></FormTableButtonRowStyle>
            </EditFormSettings>
        </MasterTableView>
        <ClientSettings>
            <ClientEvents OnRowDblClick="RowDblClick" />
        </ClientSettings>
    </telerik:RadGrid>
    <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditorNume" runat="server"
        TextBoxStyle-Width="200px" />
    <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditorPrenume" runat="server"
        TextBoxStyle-Width="200px" />
    <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnTitluDidactic" runat="server"
        DropDownStyle-Width="110px"/>
    <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnTitluStiintific" runat="server"
        DropDownStyle-Width="110px" />
    <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnColectiv" runat="server"
        DropDownStyle-Width="110px" />
    <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditorWebSite" runat="server"
        TextBoxStyle-Width="150px" />
    <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEmail" runat="server" TextBoxStyle-Width="150px" />
    <br />
    <asp:SqlDataSource ID="DataSourceProf" runat="server" ConnectionString="<%$ ConnectionStrings:SiteIEConnectionString %>"
        DeleteCommand="DELETE FROM PersonalDidactic WHERE (IdPerosnalDidactic = @IdPerosnalDidactic)"
        InsertCommand="INSERT INTO PersonalDidactic(Nume, Prenume, IdSysTitluStiintific, IdSysTitluDidactic, WebSite, Email,IdSysColectiv,Poza) VALUES (@Nume, @Prenume, @IdSysTitluStiintific, @IdSysTitluDidactic, @WebSite, @Email,@IdSysColectiv,@Poza)"
        SelectCommand="SELECT IdPerosnalDidactic, Nume,Prenume,IdSysTitluDidactic,IdSysTitluStiintific,WebSite,Email,IdSysColectiv, Poza FROM [PersonalDidactic]"
        UpdateCommand="UPDATE [PersonalDidactic] SET [Nume] = @Nume, [Prenume] = @Prenume, [IdSysTitluDidactic] =@IdSysTitluDidactic, [IdSysTitluStiintific] = @IdSysTitluStiintific, [WebSite] = @WebSite, [Email] =@Email,[IdSysColectiv]=@IdSysColectiv, Poza=@Poza WHERE [IdPerosnalDidactic] = @IdPerosnalDidactic">
        <DeleteParameters>
            <asp:Parameter Name="IdPerosnalDidactic" DbType="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="Nume" Type="String" />
            <asp:Parameter Name="Prenume" Type="String" />
            <asp:Parameter Name="IdSysTitluStiintific" Type="Int32" />
            <asp:Parameter Name="IdSysTitluDidactic" Type="Int32" />
            <asp:Parameter Name="WebSite" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="IdSysColectiv" Type="Int32" />
            <asp:Parameter Name="Poza" DbType="Binary" />
            <asp:Parameter Name="IdPerosnalDidactic" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="Nume" Type="String" />
            <asp:Parameter Name="Prenume" Type="String" />
            <asp:Parameter Name="IdSysTitluStiintific" Type="Int32" />
            <asp:Parameter Name="IdSysTitluDidactic" Type="Int32" />
            <asp:Parameter Name="WebSite" Type="String" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="IdSysColectiv" Type="Int32" />
            <asp:Parameter Name="Poza" DbType="Binary" />
        </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>
